package com.example.carbonalgorithm.common.exception;

import com.example.carbonalgorithm.common.entity.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@Slf4j
public class ExceptionHandlers {
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result exceptionHandler(Exception e) {
        System.out.println("全局异常捕获>>>:" + e);
        Result result = new Result();
        result.setState(500);
        result.setMsg(e.getMessage());
        return result;
//        return "全局异常捕获,错误原因>>>"+e.getMessage();
    }

    /* ExecutorService threadPool = Executors.newCachedThreadPool();
   FutureTask<List<MapData>> mapDataTask = new FutureTask<>(() -> largeService.findMap(data));
        threadPool.execute(mapDataTask);
        mapDataTask.get()*/
}
